export const getImageUrl = filePath => {
    let uploadsUrl = process.env.REACT_APP_BASEURL || "/";
    if (!filePath) {
        return uploadsUrl;
    } else if (filePath.indexOf("http") == 0) {
        return filePath;
    } else {
        //上传地址以 / 结尾且文件路径也以 / 开头
        if (uploadsUrl.lastIndexOf("/") == uploadsUrl.length - 1 && filePath.indexOf("/") == 0) {
            return uploadsUrl + filePath.substr(1);
        }
        //上传地址以 / 结尾且文件路径不以 / 开头   或   上传地址不以 / 结尾且文件路径以 / 开头
        if (
            (uploadsUrl.lastIndexOf("/") == uploadsUrl.length - 1 && filePath.indexOf("/") != 0) ||
            (uploadsUrl.lastIndexOf("/") != uploadsUrl.length - 1 && filePath.indexOf("/") == 0)
        ) {
            return uploadsUrl + filePath;
        }
        //上传地址、文件路径都以 / 结尾/开头
        if (uploadsUrl.lastIndexOf("/") != uploadsUrl.length - 1 && filePath.indexOf("/") != 0) {
            return uploadsUrl + "/" + filePath;
        }
        return ""
    }
};